<template>
  <div id="application-configuration" ref="application_configuration">
    <p class="title">应用配置</p>
    <div class="content-wrap" :style="{height: height}">
      <div class="condition">
        <el-tabs v-model="activeName" @tab-click="handleTabClick">
          <!------ 应用信息 ------>
          <el-tab-pane label="应用信息" name="use_msg">
            <el-main>
              <el-row>
                <el-form size="small" label-width="150px" class="demo-ruleForm">
                  <el-form-item label="应用名称：">
                    <span>{{ v3AppTitle }}</span>&nbsp;&nbsp;&nbsp;<span class="pen-point" @click="handleChangeAppData"><i class="iconfont icon-revise"></i></span>
                  </el-form-item>
                  <el-form-item label="应用包名：">
                    <span>{{ formData.app_pkg_name }}</span>&nbsp;&nbsp;&nbsp;<span class="pen-point" @click="handleChangeAppData"><i class="iconfont icon-revise"></i></span>
                  </el-form-item>
                  <el-form-item label="所属分类：">
                    <span v-if="formData.app_type">{{ appTypeArr.find(item => item.value === formData.app_type).label }}</span>
                  </el-form-item>
                 <!-- <el-form-item label="创建时间：">
                    <span>xxxxx</span>
                  </el-form-item> -->
                  <el-form-item label="APP ID：">
                    <span>{{ formData.app_key }}</span>
                  </el-form-item>
                  <el-form-item label="SECRET KEY：">
                    <span>{{ formData.secret_key }}</span>&nbsp;&nbsp;&nbsp;<span class="pen-point" @click="handleChangeKey">更换</span>
                  </el-form-item>
                  <el-form-item label="ACCESS ID：">
                    <span>{{ formData.access_id }}</span>
                  </el-form-item>
                  <el-form-item label="ACCESS KEY：">
                    <span>{{ formData.access_key }}</span>
                  </el-form-item>
                  <!-- <el-form-item label="一键接入指南：">
                    <a class="active-span" href="https://xg.qq.com/docs/android_access/jcenter.html"  target="_blank">点击查看</a>
                  </el-form-item> -->
                </el-form>
                 <el-button type="danger" class="deletapp" @click="deleteApplication">删除应用</el-button>
              </el-row>
            </el-main>
          </el-tab-pane>
          <!------ 厂商&海外通道 ------>
          <el-tab-pane label="厂商&海外通道" name="road">
            <el-main>
              <!-- <el-row>
                <span class="title-span">海外通道</span>
                <el-col>
                  <el-card class="box-card">
                    <div slot="header">
                      <span>Firebase Cloud Messaging</span>
                    </div>
                    <p>
                      在集成FCM通道之后，将具备在海外场景下进行系统级推送的能力，能够帮助应用在海外场景下快速触达用户。
                    </p>
                    <p class="is-SDK">需要安装 FCM 提供的 SDK，并且发布应用。</p>
                    <div class="card-bottom">
                      <el-button type="text">查看说明文档</el-button>
                      <el-button class="btn-right" type="text" >启用</el-button>
                    </div>
                  </el-card>
                </el-col>
              </el-row> -->
              <span class="title-span">厂商通道</span>
              <el-row>
                <el-col :span="12">
                  <el-card class="box-card">
                    <div slot="header">
                      <span>小米官方推送通道</span>
                    <el-switch
                    active-color="#0670DD"
                    inactive-color="#606870"
                    v-model="paramsone"
                    @change="paramsoneChang"
                    style="float:right">
                    </el-switch>
                    </div>
                    <div v-if="showxm">
                    <p>集成后可以在小米设备上，通过小米提供的系统级通道进行下发。</p>
                    <p class="is-SDK">需要安装小米推送SDK，并且发布应用。</p>
                    </div>
                    <div>
                      <p><span>AppID</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <span v-for="(item, index) in resultListbar" :key='index'>
                        <span v-if="item.type==='xm'" style="width:255px;display:inline-block;text-overflow:ellipsis;overflow:hidden;white-space:nowrap"> {{item.appid }} </span>
                      </span>
                      </p>
                      <p style="margin:10px 0px"><span>APPKey</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span v-for="(item, index) in resultListbar" :key='index'>
                        <span v-if="item.type==='xm'" style="width:255px;display:inline-block;text-overflow:ellipsis;overflow:hidden;white-space:nowrap"> {{item.appKey }} </span>
                      </span>
                      </p>
                      <p><span>AppSecret</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <span v-for="(item, index) in resultListbar" :key='index'>
                        <span v-if="item.type==='xm'" style="width:255px;display:inline-block;text-overflow:ellipsis;overflow:hidden;white-space:nowrap"> {{item.appsecretKey }} </span>
                      </span>
                      </p>
                    </div>
                    <div class="card-bottom">
                      <el-button type="text">查看说明文档</el-button>
                      <el-button class="btn-right" :disabled="xmshowcompiler" type="text" @click="dialogFormXm('xm')">添 加</el-button>
                      <el-button class="btn-right" type="text" @click="modifyChang('xm')" :disabled="xmshowcomdocr">编 辑</el-button>
                    </div>
                  </el-card>
                </el-col>
                <el-col :span="12">
                  <el-card class="box-card">
                    <div slot="header">
                      <span>华为官方推送通道</span>
                    <el-switch
                    active-color="#0670DD"
                    inactive-color="#606870"
                    v-model="paramstwo"
                    @change="paramstwoChang"
                    style="float:right">
                    </el-switch>
                    </div>
                    <div v-if="showxm">
                    <p>集成后可以在华为设备上，通过华为提供的系统级通道进行下发。</p>
                    <p class="is-SDK">需要安装华为推送SDK，并且发布应用。</p>
                    </div>
                   <div>
                      <p><span>AppID</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <span v-for="(item, index) in resultListbar" :key='index'>
                        <span v-if="item.type==='hw'" style="width:255px;display:inline-block;text-overflow:ellipsis;overflow:hidden;white-space:nowrap"> {{item.appid }} </span>
                      </span>
                      </p>
                     <p style="margin:10px 0px" v-if="this.showenablehw"><span>APPKey</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span v-for="(item, index) in resultListbar" :key='index'>
                        <span v-if="item.type==='hw'" style="width:255px;display:inline-block;text-overflow:ellipsis;overflow:hidden;white-space:nowrap"> {{item.appKey }} </span>
                      </span>
                      </p>
                      <p style="margin-top:40px"><span>AppSecret</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <span v-for="(item, index) in resultListbar" :key='index'>
                        <span v-if="item.type==='hw'" style="width:255px;display:inline-block;text-overflow:ellipsis;overflow:hidden;white-space:nowrap"> {{item.appsecretKey }} </span>
                      </span>
                      </p>
                    </div>
                    <div class="card-bottom">
                      <el-button type="text">查看说明文档</el-button>
                      <el-button class="btn-right" :disabled="hwshowcompiler" type="text" @click="dialogFormXm('hw')">添 加</el-button>
                      <el-button class="btn-right" type="text" @click="modifyChang('hw')" :disabled="hwshowcomdocr" >编 辑</el-button>
                    </div>
                  </el-card>
                </el-col>
              </el-row>
              <el-row>
                <el-col>
                  <el-card class="box-card" style="margin-top:15px">
                    <div slot="header">
                      <span>魅族官方推送通道</span>
                    <el-switch
                    active-color="#0670DD"
                    inactive-color="#606870"
                    v-model="paramsther"
                    @change="paramstherChang"
                    style="float:right">
                    </el-switch>
                    </div>
                    <div v-if="showxm">
                    <p>集成后可以在魅族设备上，通过魅族提供的系统级通道进行下发。</p>
                    <p class="is-SDK">需要安装魅族推送SDK，并且发布应用。</p>
                    </div>
                   <div>
                       <p><span>AppID</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <span v-for="(item, index) in resultListbar" :key='index'>
                        <span v-if="item.type==='mz'" style="width:255px;display:inline-block;text-overflow:ellipsis;overflow:hidden;white-space:nowrap"> {{item.appid }} </span>
                      </span>
                      </p>
                     <p style="margin:10px 0px"><span>APPKey</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span v-for="(item, index) in resultListbar" :key='index'>
                        <span v-if="item.type==='mz'" style="width:255px;display:inline-block;text-overflow:ellipsis;overflow:hidden;white-space:nowrap"> {{item.appKey }} </span>
                      </span>
                      </p>
                      <p><span>AppSecret</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <span v-for="(item, index) in resultListbar" :key='index'>
                        <span v-if="item.type==='mz'" style="width:255px;display:inline-block;text-overflow:ellipsis;overflow:hidden;white-space:nowrap"> {{item.appsecretKey }} </span>
                      </span>
                      </p>
                    </div>
                    <div class="card-bottom">
                      <el-button type="text">查看说明文档</el-button>
                      <el-button class="btn-right" :disabled="mzshowcompiler" type="text" @click="dialogFormXm('mz')">添 加 </el-button>
                      <el-button class="btn-right" type="text" @click="modifyChang('mz')" :disabled="mzshowcomdocr">编 辑</el-button>
                    </div>
                  </el-card>
                </el-col>
              </el-row>
            </el-main>
          </el-tab-pane>
        </el-tabs>
      </div>
    </div>
    <!-- --------------- 下面放弹框 --------------- -->
    <el-dialog title="应用信息修改" :visible.sync="changeDialog" width="30%">
      <el-form :model="formModif" label-width="80px">
        <el-form-item label="应用名称">
          <el-input v-model="formModif.title"></el-input>
        </el-form-item>
        <el-form-item label="应用包名">
          <el-input v-model="formModif.app_pkg_name"></el-input>
        </el-form-item>
      </el-form>
      <template slot="footer" class="dialog-footer">
        <el-button @click="changeDialog = false">取 消</el-button>
        <el-button type="primary" @click="handleModifConfirm">确 定</el-button>
      </template>
    </el-dialog>

     <!-- --------------- 下面放启用厂商通道新增弹框 --------------- -->
<el-dialog title="小米官方推送通道" :visible.sync="dialogFormVisiblebar">
  <span style="display:inline-block;padding:0px 15px;margin-bottom:50px"
  v-if="enableflag==='xm'">请前往小米推送官方网站注册账号，并且填写您的应用信息。
请注意：如果您的应用已经在小米推送进行过注册，请直接填入您的相关信息。</span>

  <span style="display:inline-block;padding:0px 15px;margin-bottom:50px"
  v-if="enableflag==='hw'">请前往华为推送官方网站注册账号，并且填写您的应用信息。
请注意：如果您的应用已经在华为推送进行过注册，请直接填入您的相关信息。</span>

  <span style="display:inline-block;padding:0px 15px;margin-bottom:50px"
  v-if="enableflag==='mz'">请前往魅族推送官方网站注册账号，并且填写您的应用信息。
请注意：如果您的应用已经在魅族推送进行过注册，请直接填入您的相关信息。</span>

  <el-form :model="formDatabar" style="padding:0px 20px" :rules="rules" ref="formDatabar">
    <el-form-item label="AppID" prop="appid">
      <el-input v-model="formDatabar.appid"></el-input>
    </el-form-item>
    <el-form-item label="AppKey" prop="appkey" v-if="showenable">
     <el-input v-model="formDatabar.appkey"></el-input>
    </el-form-item>
    <el-form-item label="AppSecret" prop="appsecret">
     <el-input v-model="formDatabar.appsecret"></el-input>
    </el-form-item>
  </el-form>
  <div class="dialogfooterbar">
    <el-button @click="cancelbar">取 消</el-button>
    <el-button type="primary" @click="saveData">保 存 </el-button>
  </div>
</el-dialog>

     <!-- --------------- 下面放启用厂商通道修改弹框 --------------- -->
<el-dialog title="小米官方推送通道" :visible.sync="dialogFormVisibleapp">
  <span style="display:inline-block;padding:0px 15px;margin-bottom:50px"
  v-if="typepoc==='xm'">请前往小米推送官方网站注册账号，并且填写您的应用信息。
请注意：如果您的应用已经在小米推送进行过注册，请直接填入您的相关信息。</span>

  <span style="display:inline-block;padding:0px 15px;margin-bottom:50px"
  v-if="typepoc==='hw'">请前往华为推送官方网站注册账号，并且填写您的应用信息。
请注意：如果您的应用已经在华为推送进行过注册，请直接填入您的相关信息。</span>

  <span style="display:inline-block;padding:0px 15px;margin-bottom:50px"
  v-if="typepoc==='mz'">请前往魅族推送官方网站注册账号，并且填写您的应用信息。
请注意：如果您的应用已经在魅族推送进行过注册，请直接填入您的相关信息。</span>

  <el-form :model="formDatapoc" style="padding:0px 20px" :rules="rules" ref="formDatapoc">
    <el-form-item label="AppID" prop="appidpoc">
      <el-input v-model="formDatapoc.appidpoc" :disabled="xmhshowpoc"></el-input>
    </el-form-item>
    <el-form-item label="AppKey" prop="appkeypoc" v-if="showenable">
     <el-input v-model="formDatapoc.appkeypoc"></el-input>
    </el-form-item>
    <el-form-item label="AppSecret" prop="appsecretpoc">
     <el-input v-model="formDatapoc.appsecretpoc"></el-input>
    </el-form-item>
  </el-form>
  <div class="dialogfooterbar">
    <el-button @click="cancelpoc">取 消</el-button>
    <el-button type="primary" @click="saveDatapoc">保 存 </el-button>
  </div>
</el-dialog>
  </div>
</template>

<script type="text/ecmascript-6">
  import api from '../../../../api/url'
  import ajax from '../../../../api/ajax/mobilePushAjax'
  import { APP_TYPE_ARR } from '../../comm/js/commjs'
  import { mapGetters, mapMutations } from 'vuex'
  import { nextPage } from '../../../../assets/js/index'
  import { Base64 } from 'js-base64'
  export default {
    name: 'application-configuration',
    data () {
      return {
        dialogFormVisiblebar: false,
        dialogFormVisibleapp: false,
        formData: [],
        appTypeArr: APP_TYPE_ARR,
        activeName: 'use_msg',
        tableData: [],
        resultListbar: [], // 查询的第三方通道
        formModif: {},
        changeDialog: false,
        xmshowcompiler: false, // xm禁用添加
        hwshowcompiler: false, // hw禁用添加
        mzshowcompiler: false, // mz禁用添加
        xmshowcomdocr: false, // xm禁用编辑
        hwshowcomdocr: false, // hw禁用编辑
        mzshowcomdocr: false, // mz禁用编辑
        paramsone: '', // 小米启动关闭开关的控制
        xmstatusbar: 1, // 小米默认是打开的厂商通道
        paramstwo: '', // 华为启动关闭开关的控制
        hwstatusbar: 1, // 华为默认是打开的厂商通道
        paramsther: '', // 魅族启动关闭开关的控制
        mzstatusbar: 1, // 魅族默认是打开的厂商通道
        height: null,
        typepoc: '', // 修改获取类型
        enableflag: '', // 启用的标志
        showenable: true, // 华为隐藏appkey
        showenablehw: false, // 卡片中不显示appkey
        showxm: true, // 小米的卡片隐藏
        xmhshowpoc: false, // 修改禁用appid
        formDatabar: { // 添加的表单
          appid: '',
          appkey: '',
          appsecret: ''
        },
        formDatapoc: { // 修改的表单
          appidpoc: '',
          appkeypoc: '',
          appsecretpoc: ''
        },
        rules: {
          appid: [{ required: true, message: '请输入通知标题', trigger: 'blur' }], appkey: [{ required: true, message: '请输入通知内容', trigger: 'blur' }], appsecret: [{ required: true, message: '请输入通知内容', trigger: 'blur' }], appidpoc: [{ required: true, message: '请输入通知标题', trigger: 'blur' }], appkeypoc: [{ required: true, message: '请输入通知内容', trigger: 'blur' }], appsecretpoc: [{ required: true, message: '请输入通知内容', trigger: 'blur' }]
        }
      }
    },
    computed: {
      ...mapGetters(['v3AppTitle', 'v3AppId', 'v3AppKey', 'v3SecretKey', 'storageId', 'v3platform'])
    },
    methods: {
      ...mapMutations(['v3_updateSecretKey']),
      handleTabClick (tab, eve) {
      },
      // 小米厂商通道开关控制
    paramsoneChang () {
      if (this.paramsone === true) {
        this.xmstatusbar = 1
      } else {
        this.xmstatusbar = 0
      }
      let h = {
          Authorization: 'Basic' + ' ' + Base64.encode(this.v3AppKey + ':' + this.v3SecretKey),
          'Content-Type': 'application/json'
        }
          let creatdata = {
          accessId: this.v3AppId,
          operatorType: 2,
          type: 'xm',
          status: this.xmstatusbar
         }
        ajax.post(api.update_PASSAGEWAY, creatdata, h).then(res => {
          if (res.err_msg === '操作成功') {
            this.$message({
                  message: res.err_msg,
                  type: 'success'
            })
          this.queryData()
          } else {
              this.$message({
              message: res.err_msg,
              type: 'error'
            })
          }
        })
      },
     // 华为厂商通道开关控制
    paramstwoChang () {
      if (this.paramstwo === true) {
        this.hwstatusbar = 1
      } else {
        this.hwstatusbar = 0
      }
      let h = {
          Authorization: 'Basic' + ' ' + Base64.encode(this.v3AppKey + ':' + this.v3SecretKey),
          'Content-Type': 'application/json'
        }
          let creatdata = {
          accessId: this.v3AppId,
          operatorType: 2,
          type: 'hw',
          status: this.hwstatusbar
         }
        ajax.post(api.update_PASSAGEWAY, creatdata, h).then(res => {
          if (res.err_msg === '操作成功') {
            this.$message({
                  message: res.err_msg,
                  type: 'success'
            })
            this.queryData()
          } else {
              this.$message({
              message: res.err_msg,
              type: 'error'
            })
          }
        })
      },
      // 魅族厂商通道开关控制
      paramstherChang () {
      if (this.paramsther === true) {
        this.mzstatusbar = 1
      } else {
        this.mzstatusbar = 0
      }
      let h = {
          Authorization: 'Basic' + ' ' + Base64.encode(this.v3AppKey + ':' + this.v3SecretKey),
          'Content-Type': 'application/json'
        }
          let creatdata = {
          accessId: this.v3AppId,
          operatorType: 2,
          type: 'mz',
          status: this.mzstatusbar
         }
        ajax.post(api.update_PASSAGEWAY, creatdata, h).then(res => {
          if (res.err_msg === '操作成功') {
            this.$message({
                  message: res.err_msg,
                  type: 'success'
            })
            this.queryData()
          } else {
              this.$message({
              message: res.err_msg,
              type: 'error'
            })
          }
        })
      },
      // 控制添加的弹窗显示情况
      dialogFormXm (val) {
        this.dialogFormVisiblebar = true
         if (val === 'xm') {
          this.enableflag = 'xm'
          this.showenable = true
        } else if (val === 'hw') {
          this.enableflag = 'hw'
          this.showenable = false
        } else {
           this.enableflag = 'mz'
           this.showenable = true
        }
        this.formDatabar.appid = ''
        this.formDatabar.appkey = ''
        this.formDatabar.appsecret = ''
      },
      // 删除应用
      deleteApplication () {
        this.$confirm('此操作将永久删除该应用, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
        let params = {id: this.storageId}
        ajax.post(api.LIST_DELETE_PUSH_INFO, params).then(res => {
          if (res.msg === '交易成功' && res.status === '000000') {
            this.$message({
              type: 'success',
              message: '删除成功!'
            })
            nextPage('/pushIndex')
          } else {
            this.$message({
              type: 'error',
              message: '删除失败!'
            })
          }
        }).catch(() => {})
        })
      },
      // 修改包名、名称
      handleChangeAppData () {
        this.formModif.title = this.v3AppTitle
        this.formModif.app_pkg_name = this.formData.app_pkg_name
        this.changeDialog = true
      },
      // 修改包名、名称 >> 确定修改
      handleModifConfirm () {
        this.changeDialog = false
         let h = { Authorization: 'Basic' + ' ' + Base64.encode(this.v3AppKey + ':' + this.v3SecretKey) }
        let params = {
          accessId: this.formData.access_id,
          packageName: this.formModif.app_pkg_name,
          appName: this.formModif.title
        }
        ajax.post(api.V3_APP_UPDATE, params, h).then(res => {
          if (res.ret_code === 0) {
            this.v3_updateSecretKey(params.secretKey)
            this.$message({
              type: 'success',
              message: '更新成功!'
            })
            this.queryAppDataList()
          } else {
              this.$message({
              type: 'err',
              message: '更新失败!'
            })
          }
        }).catch()
      },
      // 修改 SECRET KEY
      handleChangeKey () {
        this.$confirm('确定要更换SECRET KEY吗？更换成功后，请五分钟后再创建通知。', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.updateAppSecretKey()
        }).catch(() => {})
      },
      // SECRET KEY 值更换
      updateAppSecretKey () {
        let h = { Authorization: 'Basic' + ' ' + Base64.encode(this.v3AppKey + ':' + this.v3SecretKey) }
        let params = {
          accessId: this.formData.access_id,
          secretKey: this.randomNum()
        }
        ajax.post(api.V3_APP_UPDATE, params, h).then(res => {
          if (res.ret_code === 0) {
            this.v3_updateSecretKey(params.secretKey)
            this.$message({
              type: 'success',
              message: '更新成功!'
            })
            this.queryAppDataList()
          } else {
             this.$message({
              type: 'err',
              message: '更新失败!'
            })
          }
        }).catch()
      },
      // 查询应用信息
      queryAppDataList () {
        let h = {
          Authorization: 'Basic' + ' ' + Base64.encode(this.v3AppKey + ':' + this.v3SecretKey),
          'Content-Type': 'application/json'
        }
        ajax.get(api.V3_APP_QUERY_DATA + this.v3AppId, h).then(res => {
          if (res.ret_code === 0) {
            this.formData = res.result
          }
        })
      },
      randomNum () {
        let min = 30
        let max = 32
        let returnStr = ''
        let range = max ? Math.round(Math.random() * (max - min)) + min : min
        let charStr = 'abcdefghijklmnopqrstuvwxyz0123456789'
        for (let i = 0; i < range; i++) {
          let index = Math.round(Math.random() * (charStr.length - 1))
          returnStr += charStr.substring(index, index + 1)
        }
        return returnStr
      },
      // 添加确定提交数据
    saveData (formDatabar) {
      this.$refs.formDatabar.validate((valid) => {
        if (valid) {
        // let h = {
        //   Authorization: 'Basic' + ' ' + Base64.encode(this.v3AppKey + ':' + this.v3SecretKey),
        //   'Content-Type': 'application/json'
        // }
        // let creatdata = {
        //   accessId: this.formDatabar.appid,
        //   operatorType: 1,
        //   type: this.enableflag,
        //   appKey: this.formDatabar.appkey,
        //   appSecret: this.formDatabar.appsecret
        //  }
        // ajax.post(api.INSERT_PASSAGEWAY, creatdata, h).then(res => {
        //     if (res.err_msg === '操作成功') {
        //     this.$message({
        //           message: res.err_msg,
        //           type: 'success'
        //     })
            this.dialogFormVisiblebar = false
            this.$refs['formDatabar'].resetFields()
        //   } else {
        //       this.$message({
        //       message: res.err_msg,
        //       type: 'error'
        //     })
        //   }
        // })
        // this.queryData()
          }
      })
   },
      // 添加的取消按钮
    cancelbar () {
        this.dialogFormVisiblebar = false
        this.$refs['formDatabar'].resetFields()
    },
    // 修改的取消按钮
    cancelpoc () {
        this.dialogFormVisibleapp = false
        this.$refs['formDatapoc'].resetFields()
    },
    // 查询厂商通道
    queryData () {
        let h = {
          Authorization: 'Basic' + ' ' + Base64.encode(this.v3AppKey + ':' + this.v3SecretKey),
          'Content-Type': 'application/json'
        }
        let creatdata = {
          accessId: this.v3AppId,
          operatorType: 3
         }
        ajax.post(api.INQUIRY_PASSAGEWAY, creatdata, h).then(res => {
          console.log('5050==', res)
          if (res.err_msg === '操作成功' && res.ret_code === 0) {
              this.showxm = false
              this.resultListbar = res.result
              let xmacc = this.resultListbar.find((n) => n.type === 'xm')
              this.paramsone = xmacc.status // xm的开关状态
              let hwacc = this.resultListbar.find((n) => n.type === 'hw')
              this.paramstwo = hwacc.status // hw的开关状态
              let mzacc = this.resultListbar.find((n) => n.type === 'mz')
              this.paramsther = mzacc.status // mz的开关状态
              if (JSON.stringify(xmacc) === '{}') {
                this.xmshowcompiler = false
                this.xmshowcomdocr = true
              } else {
                this.xmshowcompiler = true
                this.xmshowcomdocr = false
              }
              if (JSON.stringify(hwacc) === '{}') {
                this.hwshowcompiler = false
                this.hwshowcomdocr = true
              } else {
                this.hwshowcompiler = true
                this.hwshowcomdocr = false
              }
              if (JSON.stringify(mzacc) === '{}') {
                this.mzshowcompiler = false
                 this.mzshowcomdocr = true
              } else {
                this.mzshowcompiler = true
                this.mzshowcomdocr = false
              }
                if (this.paramsone === 0) {
                    this.paramsone = false
                } else {
                    this.paramsone = true
                }
                if (this.paramstwo === 0) {
                   this.paramstwo = false
                } else {
                   this.paramstwo = true
                }
                if (this.paramsther === 0) {
                   this.paramsther = false
                } else {
                   this.paramsther = true
                }
          }
        })
        this.dialogFormVisiblebar = false
      },
    // 修改厂商通道
    modifyChang (val) {
      this.dialogFormVisibleapp = true
      this.xmhshowpoc = true
      let xmpoc = this.resultListbar.find((n) => n.type === 'xm')
      let hwpoc = this.resultListbar.find((n) => n.type === 'hw')
      let mzpoc = this.resultListbar.find((n) => n.type === 'mz')
        console.log('123', xmpoc, hwpoc, mzpoc)
      if ((val === 'xm') && (xmpoc.type === 'xm')) {
             this.typepoc = 'xm'
             this.showenable = true
             this.formDatapoc.appidpoc = xmpoc.appid
             this.formDatapoc.appkeypoc = xmpoc.appKey
             this.formDatapoc.appsecretpoc = xmpoc.appsecretKey
          }
      if ((val === 'hw') && (hwpoc.type === 'hw')) {
             this.typepoc = 'hw'
             this.showenable = false
             this.formDatapoc.appidpoc = hwpoc.appid
             this.formDatapoc.appkeypoc = hwpoc.appKey
             this.formDatapoc.appsecretpoc = hwpoc.appsecretKey
      }
      if ((val === 'mz') && (mzpoc.type === 'mz')) {
             this.typepoc = 'mz'
             this.showenable = true
             this.formDatapoc.appidpoc = mzpoc.appid
             this.formDatapoc.appkeypoc = mzpoc.appKey
             this.formDatapoc.appsecretpoc = mzpoc.appsecretKey
      }
    },
    // 修改提交数据
    saveDatapoc (formDatapoc) {
    this.$refs.formDatapoc.validate((valid) => {
        if (valid) {
        let hpoc = {
          Authorization: 'Basic' + ' ' + Base64.encode(this.v3AppKey + ':' + this.v3SecretKey),
          'Content-Type': 'application/json'
        }
        let creatdata = {
          accessId: this.formDatapoc.appidpoc,
          operatorType: 1,
          type: this.typepoc,
          appKey: this.formDatapoc.appkeypoc,
          appSecret: this.formDatapoc.appsecretpoc
         }
        ajax.post(api.INSERT_PASSAGEWAY, creatdata, hpoc).then(res => {
            if (res.err_msg === '操作成功') {
            this.$message({
                  message: res.err_msg,
                  type: 'success'
            })
            this.dialogFormVisibleapp = false
            this.$refs['formDatapoc'].resetFields()
          } else {
              this.$message({
              message: res.err_msg,
              type: 'error'
            })
          }
        })
        this.queryData()
        } else {
          return false
        }
    })
    }
    },
    created () {
      this.$nextTick(() => {
        this.height = this.$refs.application_configuration.offsetHeight - 60 + 'px'
      })
      this.queryAppDataList()
      this.queryData()
      if (this.v3platform === 'android') {
          nextPage('/home/applicationConfiguration')
          } else {
          nextPage('/home/applicationaInformation')
        }
    }
  }
</script>

<style lang="stylus" rel="stylesheet/stylus">
  #application-configuration
    height 100%
    background #f5f5f5
    overflow hidden
    .title
      height 60px
      padding 15px
      line-height 30px
      font-size 18px
      font-weight normal
      background #fff
    .content-wrap
      overflow auto
      margin 10px 0 0 10px
      background #ffffff
      .condition
        padding 10px
        .active-span
          color #08b1ff
          cursor pointer
        .deletapp
          display block
          text-align center
          margin 50px auto
          font-size 15px
        .title-span
          display inline-block
          margin-bottom 15px
          line-height 30px
        .box-card
          width 400px
          .is-SDK
            margin 10px 0
          .card-bottom
            overflow hidden
            .btn-right
              float right
        .pen-point
          cursor pointer
          color #08b1ff
    .dialogfooterbar
      padding-left 355px
      margin-left -45px
</style>
